﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using Maticsoft.DBUtility;

public partial class biz_down : FBasePage
{
  
    // Methods
    private void initPage()
    {
        int num;
        DataRow row;
        Maticsoft.Model.UserInfo model;
        string str3;
        if ((base.GetCookie("partnerid") == null) || (base.GetCookie("partnerid") == ""))
        {
            base.Response.Redirect("login.aspx");
        }
        if ((base.Request["id"] == null) || (base.Request["id"].ToString() == ""))
        {
            base.Response.Redirect("index.aspx");
        }
        StringBuilder builder = new StringBuilder();
        builder.Append("<html>");
        builder.Append("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");
        builder.Append("<body><table border='1'>");
        builder.Append("<tr>");
        builder.Append("<td>ID</td>");
        builder.Append("<td align='left'>订单号</td>");
        builder.Append("<td>支付号</td>");
        builder.Append("<td>支付方式</td>");
        builder.Append("<td>单价</td>");
        builder.Append("<td>数量</td>");
        builder.Append("<td>运费</td>");
        builder.Append("<td>总金额</td>");
        builder.Append("<td>支付款</td>");
        builder.Append("<td>余额付款</td>");
        builder.Append("<td>支付状态</td>");
        builder.Append("<td>备注</td>");
        builder.Append("<td>快递信息</td>");
        builder.Append("<td>用户名</td>");
        builder.Append("<td>用户邮箱</td>");
        builder.Append("<td>用户手机</td>");
        builder.Append("<td>收件人</td>");
        builder.Append("<td>手机号码</td>");
        builder.Append("<td>邮政编码</td>");
        builder.Append("<td>送货地址</td>");
        builder.Append("</tr>");
        string str = base.Request["id"].ToString();
        DataSet list = new Maticsoft.BLL.Order().GetList(" State='pay' and  Team_id=" + str);
        if (list.Tables[0].Rows.Count > 0)
        {
            for (num = 0; num < list.Tables[0].Rows.Count; num++)
            {
                row = list.Tables[0].Rows[num];
                builder.Append("<tr>");
                int num2 = num + 1;
                builder.Append("<td>" + num2.ToString() + "</td>");
                builder.Append("<td>" + row["ID"].ToString() + "</td>");
                builder.Append("<td>" + row["Pay_id"].ToString() + "</td>");
                str3 = row["Service"].ToString();
                if (str3 != null)
                {
                    if (!(str3 == "yeepay"))
                    {
                        if (str3 == "alipay")
                        {
                            goto Label_0336;
                        }
                        if (str3 == "tenpay")
                        {
                            goto Label_0344;
                        }
                        if (str3 == "chinabank")
                        {
                            goto Label_0352;
                        }
                        if (str3 == "credit")
                        {
                            goto Label_0360;
                        }
                        if (str3 == "cash")
                        {
                            goto Label_036E;
                        }
                    }
                    else
                    {
                        builder.Append("<td>易宝</td>");
                    }
                }
                goto Label_037C;
            Label_0336:
                builder.Append("<td>支付宝</td>");
                goto Label_037C;
            Label_0344:
                builder.Append("<td>财付通</td>");
                goto Label_037C;
            Label_0352:
                builder.Append("<td>网银在线</td>");
                goto Label_037C;
            Label_0360:
                builder.Append("<td>余额付款</td>");
                goto Label_037C;
            Label_036E:
                builder.Append("<td>线下支付</td>");
            Label_037C:
                builder.Append("<td>" + row["Price"].ToString() + "</td>");
                builder.Append("<td>" + row["Quantity"].ToString() + "</td>");
                builder.Append("<td>" + row["Fare"].ToString() + "</td>");
                builder.Append("<td>" + row["Origin"].ToString() + "</td>");
                builder.Append("<td>" + row["Money"].ToString() + "</td>");
                builder.Append("<td>" + row["Credit"].ToString() + "</td>");
                if (row["State"].ToString() == "pay")
                {
                    builder.Append("<td>已支付</td>");
                }
                if (row["State"].ToString() == "unpay")
                {
                    builder.Append("<td>未支付</td>");
                }
                builder.Append("<td>" + row["Remark"] + "</td>");
                builder.Append("<td>" + row["Express_no"] + "</td>");
                Maticsoft.BLL.UserInfo info = new Maticsoft.BLL.UserInfo();
                model = info.GetModel(int.Parse(row["User_id"].ToString()));
                if (model != null)
                {
                    builder.Append("<td>" + model.Username + "</td>");
                    builder.Append("<td>" + model.Email + "</td>");
                    builder.Append("<td>" + model.Mobile + "</td>");
                }
                else
                {
                    builder.Append("<td></td>");
                    builder.Append("<td></td>");
                    builder.Append("<td></td>");
                }
                builder.Append("<td>" + row["Realname"] + "</td>");
                builder.Append("<td>" + row["Mobile"] + "</td>");
                builder.Append("<td>" + row["Zipcode"] + "</td>");
                builder.Append("<td>" + row["Address"] + "</td>");
                builder.Append("</tr>");
            }
        }
        else
        {
            list = DbHelperSQL.Query("select * from [Order],orderdetail where [Order].Id=orderdetail.Order_id and  Teamid=" + str + " and State='pay'");
            if (list.Tables[0].Rows.Count > 0)
            {
                for (num = 0; num < list.Tables[0].Rows.Count; num++)
                {
                    row = list.Tables[0].Rows[num];
                    builder.Append("<tr>");
                    builder.Append("<td>" + ((num + 1)).ToString() + "</td>");
                    builder.Append("<td>" + row["ID"].ToString() + "</td>");
                    builder.Append("<td>" + row["Pay_id"].ToString() + "</td>");
                    str3 = row["Service"].ToString();
                    if (str3 != null)
                    {
                        if (!(str3 == "yeepay"))
                        {
                            if (str3 == "alipay")
                            {
                                goto Label_07DF;
                            }
                            if (str3 == "tenpay")
                            {
                                goto Label_07ED;
                            }
                            if (str3 == "chinabank")
                            {
                                goto Label_07FB;
                            }
                            if (str3 == "credit")
                            {
                                goto Label_0809;
                            }
                            if (str3 == "cash")
                            {
                                goto Label_0817;
                            }
                        }
                        else
                        {
                            builder.Append("<td>易宝</td>");
                        }
                    }
                    goto Label_0825;
                Label_07DF:
                    builder.Append("<td>支付宝</td>");
                    goto Label_0825;
                Label_07ED:
                    builder.Append("<td>财付通</td>");
                    goto Label_0825;
                Label_07FB:
                    builder.Append("<td>网银在线</td>");
                    goto Label_0825;
                Label_0809:
                    builder.Append("<td>余额付款</td>");
                    goto Label_0825;
                Label_0817:
                    builder.Append("<td>线下支付</td>");
                Label_0825:
                    builder.Append("<td>" + row["Price"].ToString() + "</td>");
                    builder.Append("<td>" + row["Quantity"].ToString() + "</td>");
                    builder.Append("<td>" + row["Fare"].ToString() + "</td>");
                    builder.Append("<td>" + row["Origin"].ToString() + "</td>");
                    builder.Append("<td>" + row["Money"].ToString() + "</td>");
                    builder.Append("<td>" + row["Credit"].ToString() + "</td>");
                    if (row["State"].ToString() == "pay")
                    {
                        builder.Append("<td>已支付</td>");
                    }
                    if (row["State"].ToString() == "unpay")
                    {
                        builder.Append("<td>未支付</td>");
                    }
                    builder.Append("<td>" + row["Remark"] + "</td>");
                    builder.Append("<td>" + row["Express_no"] + "</td>");
                    model = new Maticsoft.BLL.UserInfo().GetModel(int.Parse(row["User_id"].ToString()));
                    if (model != null)
                    {
                        builder.Append("<td>" + model.Username + "</td>");
                        builder.Append("<td>" + model.Email + "</td>");
                        builder.Append("<td>" + model.Mobile + "</td>");
                    }
                    else
                    {
                        builder.Append("<td></td>");
                        builder.Append("<td></td>");
                        builder.Append("<td></td>");
                    }
                    builder.Append("<td>" + row["Realname"] + "</td>");
                    builder.Append("<td>" + row["Mobile"] + "</td>");
                    builder.Append("<td>" + row["Zipcode"] + "</td>");
                    builder.Append("<td>" + row["Address"] + "</td>");
                    builder.Append("</tr>");
                }
            }
        }
        builder.Append("</table></body></html>");
        string s = builder.ToString();
        base.Response.ClearHeaders();
        base.Response.Clear();
        base.Response.Expires = 0;
        base.Response.Buffer = true;
        base.Response.AddHeader("Accept-Language", "zh-tw");
        base.Response.AddHeader("content-disposition", "attachment; filename=" + HttpUtility.UrlEncode("Order_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls", Encoding.UTF8));
        base.Response.ContentType = "Application/octet-stream";
        base.Response.Write(s);
        base.Response.End();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!this.Page.IsPostBack)
        {
            this.initPage();
        }
    }

}